import { IModal, IViewProvider, ViewController } from '@ibiz-template/runtime';
import { IAppView } from '@ibiz/model-core';
import { defineComponent, PropType } from 'vue';
import { useNamespace, useViewController } from '@ibiz-template/vue3-util';
import './view.scss';

export const ViewPlugin = defineComponent({
  name: 'IBizViewPlugin',
  props: {
    context: Object as PropType<IContext>,
    params: { type: Object as PropType<IParams>, default: () => ({}) },
    modelData: { type: Object as PropType<IAppView>, required: true },
    modal: { type: Object as PropType<IModal> },
    state: { type: Object as PropType<IData> },
    provider: { type: Object as PropType<IViewProvider> },
  },
  setup() {
    const ns = useNamespace('view-plugin');
    const c = useViewController((...args) => new ViewController(...args));

    return {
      ns,
      c,
    };
  },
  render() {
    return (
      <div ref='container' class={this.ns.b()}>
        这是一个视图插件
      </div>
    );
  },
});
